1. Technical Field
The present invention is generally directed to an improved data processing system. More specifically, the present invention is directed to a method and system for obtaining memory usage information for a heap when a peak live count is updated.
2. Description of Related Art
The memory utilization of a JAVA™ heap is an important characteristic of program performance. Whenever a class instance or array is created in a running JAVA application, the memory of the new object is allocated from a single heap. Because a JAVA application runs inside its “own” exclusive Java Virtual Machine (JVM) instance, a separate heap exists for every individual running application. As only one heap exists inside a Java Virtual Machine instance, all threads share it.
A “new” construct in Java is supported in the JVM by allocating memory on the heap for a new object but Java includes no instruction for freeing that memory. The virtual machine itself is responsible for deciding whether and when to free memory occupied by objects that are no longer reference by the running application. Usually, a JVM implementation uses a garbage collector to manage the heap and clean up the heap, i.e. identify objects that no longer have active references in the running application to them and free the memory associated with these “dead” objects.
The garbage collector's primary function is to automatically reclaim the memory used by objects that are no longer reference by the running application. It also can move objects as the application runs to reduce heap fragmentation. The memory that makes up the heap need not be contiguous and can be expanded and contracted as the running program progresses.
Since the heap is a limited resource, it is important to know the live set, i.e. the set of objects that are currently referenced by the running application, at any point in time. The difficulty in obtaining this metric is due to the fact that there is no explicit free event, i.e. an explicit event that itself frees memory associated with “dead” objects, as discussed above. Objects are implicitly freed by reference updating (even an allocation can be freeing memory space) or scope changes (e.g., method/block exits), but this information is not readily available to the user of performance tooling. Because of this, it is not known at any given time the amount of real live data in the heap. Information about the live set only becomes explicitly available at the time of a full garbage collection and this information may not be completely accurate due to enhanced sweeping mechanisms.
There are numerous situations where this information about the live set is invaluable. For example, with Internet based computing systems, administrators may be interested in understanding and planning for the heap requirements given certain inputs. That is, given a business object of a certain size, it is desirable to determine what the heap requirements are for this object as it flows through the JVM. Actually feeding the business object through the system and observing is possible, however due to reasons above, there is no way to observe or measure the information. Thus, it would be desirable to have a method and system for determining the memory utilization of a heap at any time during operation of the computing system.